
module libeventd.Types ;


public import
	tango.stdc.signal ,
	tango.net.device.Berkeley ;

version(Windows){
	public import
		tango.sys.win32.UserGdi ,
		tango.sys.win32.WsaSock ;
}


public import

	libeventd.Event ,

	libeventd.Buffer,
	libeventd.buffer.Iocp,

	libeventd.buffer.Event,
	libeventd.buffer.event.Async ,
	libeventd.buffer.event.Struct,
	libeventd.buffer.event.Ssl,
	libeventd.buffer.event.Internal ,

	libeventd.changelist.Internal,

	libeventd.defer.Internal,

	libeventd.Dns,
	libeventd.dns.Struct,

	libeventd.event.Struct  ,
	libeventd.event.Internal ,

	libeventd.EvBuffer,
	libeventd.evbuffer.Internal,

	libeventd.EvDns ,

	libeventd.Http,
	libeventd.http.Intelnal ,
	libeventd.http.Struct ,
	
	libeventd.miniheap.Intenal,

	libeventd.Rpc,
 	libeventd.rpc.Struct,
	libeventd.rpc.Intelnal,
 
	libeventd.Listener,
	libeventd.EvMap,
	libeventd.EvSignal,
	
	libeventd.ratelim.Internal ,

	libeventd.Thread ,
	libeventd.Util;
	
version(Windows){
	
	public import 
 		libeventd.iocp.Internal ;
}

alias ptrdiff_t	ev_ssize_t ;
alias size_t	ev_size_t ;

alias ubyte	ev_uint8_t;

alias short		ev_short;
alias ushort	ev_ushort ;
alias ushort	ev_uint16_t ;

alias uint		ev_ulong , 
			ev_uint ,
			ev_uint32,
			ev_uint32_t;

alias int		ev_long , 
			ev_int ,
			ev_int32 ,
			ev_int32_t;
			
alias int		off_t;
alias	uint		ev_uintptr_t;

alias long		ev_off_t ;
alias ulong		ev_uint64_t;
alias long		ev_int64_t;

alias tango.net.device.Berkeley.socket_t			evutil_socket_t ;
alias tango.net.device.Berkeley.Address.sockaddr	sockaddr;
alias tango.net.device.Berkeley.Address.sockaddr	sockaddr_in;

version(TAILQ_ENTRY) {
} else {
	version =	_EVENT_DEFINED_TQENTRY;
	struct TAILQ_ENTRY(type) {
		type*	tqe_next;	/* next element */
		type**	tqe_prev;	/* address of previous next element */
	}
	
	template TAILQ_HEAD( type) {
		type*	tqh_first;
		type**	tqh_last;
		
		type* top(){
			return tqh_first ;
		}
	}
}

template HT_HEAD(type) {
    type**	hth_table;
    uint	hth_table_length; 
    uint	hth_n_entries;
    uint	hth_load_limit;
    int	hth_prime_idx;
}

struct timeval{
	int	tv_sec, tv_usec; 
}


enum event_method_feature {
	/* Require an event method that allows edge-triggered events with EV_ET. */
	EV_FEATURE_ET = 0x01 ,
	/* Require an event method where having one event triggered among
	* many is [approximately] an O(1) operation. This excludes (for
	* example) select and poll, which are approximately O(N) for N
	* equal to the total number of possible events. */
	EV_FEATURE_O1 = 0x02 ,
	/* Require an event method that allows file descriptors as well as
	* sockets. */
	EV_FEATURE_FDS = 0x04 
}

enum event_base_config_flag {
	/** Do not allocate a lock for the event base, even if we have
	    locking set up. */
	EVENT_BASE_FLAG_NOLOCK	= 0x01 ,
	/** Do not check the EVENT_NO* environment variables when picking
	    an event_base. */
	EVENT_BASE_FLAG_IGNORE_ENV	= 0x02 ,
	/** Windows only: enable the IOCP dispatcher at startup */
	EVENT_BASE_FLAG_STARTUP_IOCP	= 0x04 ,
	/** Instead of checking the current time every time the event loop is
	    ready to run timeout callbacks, check after each timeout callback.
	 */
	EVENT_BASE_FLAG_NO_CACHE_TIME	= 0x08 ,
}


extern(C){
	void printf(char*,...);
}

version(Windows){
	extern(Windows) int CryptAcquireContextA(void*,void*,void*,void*, void*);
	extern(C) int CryptAcquireContext(void* p1,void* p2,void* p3,void* p4, void* p5){
		return CryptAcquireContextA(p1, p2, p3, p4, p5);
	}
	
	extern(C) long _lseeki64(void* fd, long offset, int origin){
		assert(false);
		return _llseek(fd, offset, origin);
	}
	
	extern(C) int _fstati64(void* fd, void* sate){
		assert(false);
		return 0 ;
	}
	
}